package com.cy.sys.controller;

import com.cy.common.pojo.JsonResult;
import com.cy.sys.dao.SysMenuDao;
import com.cy.sys.pojo.RoleMenus;
import com.cy.sys.pojo.Sysmenu;
import com.cy.sys.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/menu/")
public class sysMenuController {
    @Autowired
    private MenuService menu;

    @RequestMapping("doFindObjects")
    @ResponseBody

    public JsonResult doFindObjects(){
        Object a=menu.dofindMenuAll();

        return new JsonResult(a);
    }
    @RequestMapping("doDeleteObject")
    @ResponseBody
    public JsonResult doDeleteObject(Integer id){
        System.out.println(id);
        menu.doDeleteObject(id);

        return new JsonResult("delete ok");
    }
    @RequestMapping("doFindZtreeMenuNodes")
    @ResponseBody
    public JsonResult doFindZtreeMenuNodes(){

        return new JsonResult(menu.dofindMenuAll());
    }
    @RequestMapping("doSaveObject")
    @ResponseBody
    public JsonResult doSaveObject(RoleMenus roleMenus){
        menu.insertObject(roleMenus);

        return new JsonResult("添加成功");
    }
    @RequestMapping("doUpdateObject")
    @ResponseBody
    public JsonResult doUpdateObject(RoleMenus roleMenus){
        menu.doUpdateObject(roleMenus);

        return  new JsonResult("修改成功");
    }
}
